package nl.uva.science.pico.picolanguage;

public class Factory {
  private aterm.pure.PureFactory factory;


  private aterm.AFun fun_Normal_Normal;
  private aterm.ATerm pattern_Normal_Normal;

  private aterm.AFun fun_Escaped_Escaped;
  private aterm.ATerm pattern_Escaped_Escaped;

  private aterm.AFun fun_StrCon_StrCon;
  private aterm.ATerm pattern_StrCon_StrCon;

  private aterm.AFun fun_BoolCon_True;
  private aterm.ATerm pattern_BoolCon_True;
  private aterm.AFun fun_BoolCon_False;
  private aterm.ATerm pattern_BoolCon_False;

  private aterm.AFun fun_NatCon_NatCon;
  private aterm.ATerm pattern_NatCon_NatCon;

  private aterm.AFun fun_TYPE_Natural;
  private aterm.ATerm pattern_TYPE_Natural;
  private aterm.AFun fun_TYPE_String;
  private aterm.ATerm pattern_TYPE_String;
  private aterm.AFun fun_TYPE_NilType;
  private aterm.ATerm pattern_TYPE_NilType;

  private aterm.AFun fun_PICOID_PICOID;
  private aterm.ATerm pattern_PICOID_PICOID;

  private aterm.AFun fun_STATEMENTS_Statements;
  private aterm.ATerm pattern_STATEMENTS_Statements;

  private aterm.AFun fun_DECLARATIONS_Declarations;
  private aterm.ATerm pattern_DECLARATIONS_Declarations;

  private aterm.AFun fun_PROGRAM_Main;
  private aterm.ATerm pattern_PROGRAM_Main;

  private aterm.AFun fun_DECLS_Variables;
  private aterm.ATerm pattern_DECLS_Variables;

  private aterm.AFun fun_IDTYPE_Variable;
  private aterm.ATerm pattern_IDTYPE_Variable;

  private aterm.AFun fun_STATEMENT_Assignment;
  private aterm.ATerm pattern_STATEMENT_Assignment;
  private aterm.AFun fun_STATEMENT_Conditional;
  private aterm.ATerm pattern_STATEMENT_Conditional;
  private aterm.AFun fun_STATEMENT_Loop;
  private aterm.ATerm pattern_STATEMENT_Loop;

  private aterm.AFun fun_EXP_Variable;
  private aterm.ATerm pattern_EXP_Variable;
  private aterm.AFun fun_EXP_NumberValue;
  private aterm.ATerm pattern_EXP_NumberValue;
  private aterm.AFun fun_EXP_StringValue;
  private aterm.ATerm pattern_EXP_StringValue;
  private aterm.AFun fun_EXP_Add;
  private aterm.ATerm pattern_EXP_Add;
  private aterm.AFun fun_EXP_Subtract;
  private aterm.ATerm pattern_EXP_Subtract;
  private aterm.AFun fun_EXP_Concatenate;
  private aterm.ATerm pattern_EXP_Concatenate;
  private aterm.AFun fun_EXP_Bracket;
  private aterm.ATerm pattern_EXP_Bracket;



  private nl.uva.science.pico.picolanguage.types.STATEMENTList empty_STATEMENTList;
  private nl.uva.science.pico.picolanguage.types.IDTYPEList empty_IDTYPEList;

  private Factory(aterm.pure.PureFactory factory) {
    this.factory = factory;
  }

  private static Factory instance = null;

  public synchronized static Factory getInstance(aterm.pure.PureFactory factory) {
    if (instance == null) {
        instance = new Factory(factory);
        instance.initialize();
    }
    if (instance.factory != factory) {
        throw new RuntimeException("Don't create two Factory factories with differents PureFactory ");
    }
    return instance;
  }

  public aterm.pure.PureFactory getPureFactory() {
    return factory;
  }

  private void initialize() {

    pattern_Normal_Normal = factory.parse("<str>");
    fun_Normal_Normal = factory.makeAFun("_Normal_Normal", 1, false);

    pattern_Escaped_Escaped = factory.parse("<str>");
    fun_Escaped_Escaped = factory.makeAFun("_Escaped_Escaped", 1, false);

    pattern_StrCon_StrCon = factory.parse("<str>");
    fun_StrCon_StrCon = factory.makeAFun("_StrCon_StrCon", 1, false);

    pattern_BoolCon_True = factory.parse("true");
    fun_BoolCon_True = factory.makeAFun("_BoolCon_true", 0, false);

    pattern_BoolCon_False = factory.parse("false");
    fun_BoolCon_False = factory.makeAFun("_BoolCon_false", 0, false);

    pattern_NatCon_NatCon = factory.parse("<str>");
    fun_NatCon_NatCon = factory.makeAFun("_NatCon_NatCon", 1, false);

    pattern_TYPE_Natural = factory.parse("natural");
    fun_TYPE_Natural = factory.makeAFun("_TYPE_natural", 0, false);

    pattern_TYPE_String = factory.parse("string");
    fun_TYPE_String = factory.makeAFun("_TYPE_string", 0, false);

    pattern_TYPE_NilType = factory.parse("nil-type");
    fun_TYPE_NilType = factory.makeAFun("_TYPE_nil-type", 0, false);

    pattern_PICOID_PICOID = factory.parse("<str>");
    fun_PICOID_PICOID = factory.makeAFun("_PICO-ID_PICO-ID", 1, false);

    pattern_STATEMENTS_Statements = factory.parse("statements(<term>)");
    fun_STATEMENTS_Statements = factory.makeAFun("_STATEMENTS_statements", 1, false);

    pattern_DECLARATIONS_Declarations = factory.parse("declarations(<term>)");
    fun_DECLARATIONS_Declarations = factory.makeAFun("_DECLARATIONS_declarations", 1, false);

    pattern_PROGRAM_Main = factory.parse("main(<term>,<term>)");
    fun_PROGRAM_Main = factory.makeAFun("_PROGRAM_main", 2, false);

    pattern_DECLS_Variables = factory.parse("variables(<term>)");
    fun_DECLS_Variables = factory.makeAFun("_DECLS_variables", 1, false);

    pattern_IDTYPE_Variable = factory.parse("variable(<term>,<term>)");
    fun_IDTYPE_Variable = factory.makeAFun("_ID-TYPE_variable", 2, false);

    pattern_STATEMENT_Assignment = factory.parse("assignment(<term>,<term>)");
    fun_STATEMENT_Assignment = factory.makeAFun("_STATEMENT_assignment", 2, false);

    pattern_STATEMENT_Conditional = factory.parse("conditional(<term>,<term>,<term>)");
    fun_STATEMENT_Conditional = factory.makeAFun("_STATEMENT_conditional", 3, false);

    pattern_STATEMENT_Loop = factory.parse("loop(<term>,<term>)");
    fun_STATEMENT_Loop = factory.makeAFun("_STATEMENT_loop", 2, false);

    pattern_EXP_Variable = factory.parse("variable(<term>)");
    fun_EXP_Variable = factory.makeAFun("_EXP_variable", 1, false);

    pattern_EXP_NumberValue = factory.parse("number-value(<int>)");
    fun_EXP_NumberValue = factory.makeAFun("_EXP_number-value", 1, false);

    pattern_EXP_StringValue = factory.parse("string-value(<str>)");
    fun_EXP_StringValue = factory.makeAFun("_EXP_string-value", 1, false);

    pattern_EXP_Add = factory.parse("add(<term>,<term>)");
    fun_EXP_Add = factory.makeAFun("_EXP_add", 2, false);

    pattern_EXP_Subtract = factory.parse("subtract(<term>,<term>)");
    fun_EXP_Subtract = factory.makeAFun("_EXP_subtract", 2, false);

    pattern_EXP_Concatenate = factory.parse("concatenate(<term>,<term>)");
    fun_EXP_Concatenate = factory.makeAFun("_EXP_concatenate", 2, false);

    pattern_EXP_Bracket = factory.parse("bracket(<term>)");
    fun_EXP_Bracket = factory.makeAFun("_EXP_bracket", 1, false);

    empty_STATEMENTList = (nl.uva.science.pico.picolanguage.types.STATEMENTList) factory.build(new nl.uva.science.pico.picolanguage.types.STATEMENTList(this, factory.getEmpty(), null, null));
    empty_IDTYPEList = (nl.uva.science.pico.picolanguage.types.IDTYPEList) factory.build(new nl.uva.science.pico.picolanguage.types.IDTYPEList(this, factory.getEmpty(), null, null));
  }

/*genAlternativeMethods*/
  public nl.uva.science.pico.picolanguage.types.normal.Normal makeNormal_Normal(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.normal.Normal) factory.build( new nl.uva.science.pico.picolanguage.types.normal.Normal(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.normal.Normal makeNormal_Normal(String _string) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_string, 0, true))};
    return makeNormal_Normal(fun_Normal_Normal, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.Normal Normal_NormalFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_Normal_Normal);

    if (children != null) {
      return makeNormal_Normal(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.normal.Normal arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getString());
    return factory.make(pattern_Normal_Normal, args);
  }

  public nl.uva.science.pico.picolanguage.types.escaped.Escaped makeEscaped_Escaped(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.escaped.Escaped) factory.build( new nl.uva.science.pico.picolanguage.types.escaped.Escaped(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.escaped.Escaped makeEscaped_Escaped(String _string) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_string, 0, true))};
    return makeEscaped_Escaped(fun_Escaped_Escaped, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.Escaped Escaped_EscapedFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_Escaped_Escaped);

    if (children != null) {
      return makeEscaped_Escaped(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.escaped.Escaped arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getString());
    return factory.make(pattern_Escaped_Escaped, args);
  }

  public nl.uva.science.pico.picolanguage.types.strcon.StrCon makeStrCon_StrCon(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.strcon.StrCon) factory.build( new nl.uva.science.pico.picolanguage.types.strcon.StrCon(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.strcon.StrCon makeStrCon_StrCon(String _string) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_string, 0, true))};
    return makeStrCon_StrCon(fun_StrCon_StrCon, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.StrCon StrCon_StrConFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_StrCon_StrCon);

    if (children != null) {
      return makeStrCon_StrCon(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.strcon.StrCon arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getString());
    return factory.make(pattern_StrCon_StrCon, args);
  }

  public nl.uva.science.pico.picolanguage.types.boolcon.True makeBoolCon_True(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.boolcon.True) factory.build( new nl.uva.science.pico.picolanguage.types.boolcon.True(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.boolcon.True makeBoolCon_True() {
    aterm.ATerm[] args = new aterm.ATerm[] {};
    return makeBoolCon_True(fun_BoolCon_True, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.BoolCon BoolCon_TrueFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_BoolCon_True);

    if (children != null) {
      return makeBoolCon_True(
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.boolcon.True arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    return factory.make(pattern_BoolCon_True, args);
  }

  public nl.uva.science.pico.picolanguage.types.boolcon.False makeBoolCon_False(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.boolcon.False) factory.build( new nl.uva.science.pico.picolanguage.types.boolcon.False(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.boolcon.False makeBoolCon_False() {
    aterm.ATerm[] args = new aterm.ATerm[] {};
    return makeBoolCon_False(fun_BoolCon_False, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.BoolCon BoolCon_FalseFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_BoolCon_False);

    if (children != null) {
      return makeBoolCon_False(
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.boolcon.False arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    return factory.make(pattern_BoolCon_False, args);
  }

  public nl.uva.science.pico.picolanguage.types.natcon.NatCon makeNatCon_NatCon(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.natcon.NatCon) factory.build( new nl.uva.science.pico.picolanguage.types.natcon.NatCon(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.natcon.NatCon makeNatCon_NatCon(String _string) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_string, 0, true))};
    return makeNatCon_NatCon(fun_NatCon_NatCon, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.NatCon NatCon_NatConFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_NatCon_NatCon);

    if (children != null) {
      return makeNatCon_NatCon(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.natcon.NatCon arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getString());
    return factory.make(pattern_NatCon_NatCon, args);
  }

  public nl.uva.science.pico.picolanguage.types.type.Natural makeTYPE_Natural(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.type.Natural) factory.build( new nl.uva.science.pico.picolanguage.types.type.Natural(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.type.Natural makeTYPE_Natural() {
    aterm.ATerm[] args = new aterm.ATerm[] {};
    return makeTYPE_Natural(fun_TYPE_Natural, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.TYPE TYPE_NaturalFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_TYPE_Natural);

    if (children != null) {
      return makeTYPE_Natural(
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.type.Natural arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    return factory.make(pattern_TYPE_Natural, args);
  }

  public nl.uva.science.pico.picolanguage.types.type.String makeTYPE_String(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.type.String) factory.build( new nl.uva.science.pico.picolanguage.types.type.String(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.type.String makeTYPE_String() {
    aterm.ATerm[] args = new aterm.ATerm[] {};
    return makeTYPE_String(fun_TYPE_String, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.TYPE TYPE_StringFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_TYPE_String);

    if (children != null) {
      return makeTYPE_String(
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.type.String arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    return factory.make(pattern_TYPE_String, args);
  }

  public nl.uva.science.pico.picolanguage.types.type.NilType makeTYPE_NilType(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.type.NilType) factory.build( new nl.uva.science.pico.picolanguage.types.type.NilType(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.type.NilType makeTYPE_NilType() {
    aterm.ATerm[] args = new aterm.ATerm[] {};
    return makeTYPE_NilType(fun_TYPE_NilType, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.TYPE TYPE_NilTypeFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_TYPE_NilType);

    if (children != null) {
      return makeTYPE_NilType(
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.type.NilType arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    return factory.make(pattern_TYPE_NilType, args);
  }

  public nl.uva.science.pico.picolanguage.types.picoid.PICOID makePICOID_PICOID(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.picoid.PICOID) factory.build( new nl.uva.science.pico.picolanguage.types.picoid.PICOID(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.picoid.PICOID makePICOID_PICOID(String _string) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_string, 0, true))};
    return makePICOID_PICOID(fun_PICOID_PICOID, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.PICOID PICOID_PICOIDFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_PICOID_PICOID);

    if (children != null) {
      return makePICOID_PICOID(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.picoid.PICOID arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getString());
    return factory.make(pattern_PICOID_PICOID, args);
  }

  public nl.uva.science.pico.picolanguage.types.statements.Statements makeSTATEMENTS_Statements(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.statements.Statements) factory.build( new nl.uva.science.pico.picolanguage.types.statements.Statements(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.statements.Statements makeSTATEMENTS_Statements(nl.uva.science.pico.picolanguage.types.STATEMENTList _list) {
    aterm.ATerm[] args = new aterm.ATerm[] {_list};
    return makeSTATEMENTS_Statements(fun_STATEMENTS_Statements, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.STATEMENTS STATEMENTS_StatementsFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_STATEMENTS_Statements);

    if (children != null) {
      return makeSTATEMENTS_Statements(
        STATEMENTListFromTerm((aterm.ATerm) children.get(0))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.statements.Statements arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getList().toTerm());
    return factory.make(pattern_STATEMENTS_Statements, args);
  }

  public nl.uva.science.pico.picolanguage.types.declarations.Declarations makeDECLARATIONS_Declarations(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.declarations.Declarations) factory.build( new nl.uva.science.pico.picolanguage.types.declarations.Declarations(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.declarations.Declarations makeDECLARATIONS_Declarations(nl.uva.science.pico.picolanguage.types.IDTYPEList _list) {
    aterm.ATerm[] args = new aterm.ATerm[] {_list};
    return makeDECLARATIONS_Declarations(fun_DECLARATIONS_Declarations, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.DECLARATIONS DECLARATIONS_DeclarationsFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_DECLARATIONS_Declarations);

    if (children != null) {
      return makeDECLARATIONS_Declarations(
        IDTYPEListFromTerm((aterm.ATerm) children.get(0))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.declarations.Declarations arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getList().toTerm());
    return factory.make(pattern_DECLARATIONS_Declarations, args);
  }

  public nl.uva.science.pico.picolanguage.types.program.Main makePROGRAM_Main(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.program.Main) factory.build( new nl.uva.science.pico.picolanguage.types.program.Main(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.program.Main makePROGRAM_Main(nl.uva.science.pico.picolanguage.types.DECLS _declarations, nl.uva.science.pico.picolanguage.types.STATEMENTS _body) {
    aterm.ATerm[] args = new aterm.ATerm[] {_declarations, _body};
    return makePROGRAM_Main(fun_PROGRAM_Main, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.PROGRAM PROGRAM_MainFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_PROGRAM_Main);

    if (children != null) {
      return makePROGRAM_Main(
        DECLSFromTerm((aterm.ATerm) children.get(0)),
        STATEMENTSFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.program.Main arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getDeclarations().toTerm());
    args.add(arg.getBody().toTerm());
    return factory.make(pattern_PROGRAM_Main, args);
  }

  public nl.uva.science.pico.picolanguage.types.decls.Variables makeDECLS_Variables(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.decls.Variables) factory.build( new nl.uva.science.pico.picolanguage.types.decls.Variables(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.decls.Variables makeDECLS_Variables(nl.uva.science.pico.picolanguage.types.DECLARATIONS _declarations) {
    aterm.ATerm[] args = new aterm.ATerm[] {_declarations};
    return makeDECLS_Variables(fun_DECLS_Variables, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.DECLS DECLS_VariablesFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_DECLS_Variables);

    if (children != null) {
      return makeDECLS_Variables(
        DECLARATIONSFromTerm((aterm.ATerm) children.get(0))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.decls.Variables arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getDeclarations().toTerm());
    return factory.make(pattern_DECLS_Variables, args);
  }

  public nl.uva.science.pico.picolanguage.types.idtype.Variable makeIDTYPE_Variable(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.idtype.Variable) factory.build( new nl.uva.science.pico.picolanguage.types.idtype.Variable(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.idtype.Variable makeIDTYPE_Variable(nl.uva.science.pico.picolanguage.types.PICOID _variableName, nl.uva.science.pico.picolanguage.types.TYPE _variableType) {
    aterm.ATerm[] args = new aterm.ATerm[] {_variableName, _variableType};
    return makeIDTYPE_Variable(fun_IDTYPE_Variable, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.IDTYPE IDTYPE_VariableFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_IDTYPE_Variable);

    if (children != null) {
      return makeIDTYPE_Variable(
        PICOIDFromTerm((aterm.ATerm) children.get(0)),
        TYPEFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.idtype.Variable arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getVariableName().toTerm());
    args.add(arg.getVariableType().toTerm());
    return factory.make(pattern_IDTYPE_Variable, args);
  }

  public nl.uva.science.pico.picolanguage.types.statement.Assignment makeSTATEMENT_Assignment(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.statement.Assignment) factory.build( new nl.uva.science.pico.picolanguage.types.statement.Assignment(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.statement.Assignment makeSTATEMENT_Assignment(nl.uva.science.pico.picolanguage.types.PICOID _PICOID, nl.uva.science.pico.picolanguage.types.EXP _EXP) {
    aterm.ATerm[] args = new aterm.ATerm[] {_PICOID, _EXP};
    return makeSTATEMENT_Assignment(fun_STATEMENT_Assignment, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENT_AssignmentFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_STATEMENT_Assignment);

    if (children != null) {
      return makeSTATEMENT_Assignment(
        PICOIDFromTerm((aterm.ATerm) children.get(0)),
        EXPFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.statement.Assignment arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getPICOID().toTerm());
    args.add(arg.getEXP().toTerm());
    return factory.make(pattern_STATEMENT_Assignment, args);
  }

  public nl.uva.science.pico.picolanguage.types.statement.Conditional makeSTATEMENT_Conditional(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.statement.Conditional) factory.build( new nl.uva.science.pico.picolanguage.types.statement.Conditional(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.statement.Conditional makeSTATEMENT_Conditional(nl.uva.science.pico.picolanguage.types.EXP _condition, nl.uva.science.pico.picolanguage.types.STATEMENTS _ifBranch, nl.uva.science.pico.picolanguage.types.STATEMENTS _elseBranch) {
    aterm.ATerm[] args = new aterm.ATerm[] {_condition, _ifBranch, _elseBranch};
    return makeSTATEMENT_Conditional(fun_STATEMENT_Conditional, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENT_ConditionalFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_STATEMENT_Conditional);

    if (children != null) {
      return makeSTATEMENT_Conditional(
        EXPFromTerm((aterm.ATerm) children.get(0)),
        STATEMENTSFromTerm((aterm.ATerm) children.get(1)),
        STATEMENTSFromTerm((aterm.ATerm) children.get(2))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.statement.Conditional arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getCondition().toTerm());
    args.add(arg.getIfBranch().toTerm());
    args.add(arg.getElseBranch().toTerm());
    return factory.make(pattern_STATEMENT_Conditional, args);
  }

  public nl.uva.science.pico.picolanguage.types.statement.Loop makeSTATEMENT_Loop(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.statement.Loop) factory.build( new nl.uva.science.pico.picolanguage.types.statement.Loop(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.statement.Loop makeSTATEMENT_Loop(nl.uva.science.pico.picolanguage.types.EXP _condition, nl.uva.science.pico.picolanguage.types.STATEMENTS _body) {
    aterm.ATerm[] args = new aterm.ATerm[] {_condition, _body};
    return makeSTATEMENT_Loop(fun_STATEMENT_Loop, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENT_LoopFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_STATEMENT_Loop);

    if (children != null) {
      return makeSTATEMENT_Loop(
        EXPFromTerm((aterm.ATerm) children.get(0)),
        STATEMENTSFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.statement.Loop arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getCondition().toTerm());
    args.add(arg.getBody().toTerm());
    return factory.make(pattern_STATEMENT_Loop, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.Variable makeEXP_Variable(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.Variable) factory.build( new nl.uva.science.pico.picolanguage.types.exp.Variable(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.Variable makeEXP_Variable(nl.uva.science.pico.picolanguage.types.PICOID _variableName) {
    aterm.ATerm[] args = new aterm.ATerm[] {_variableName};
    return makeEXP_Variable(fun_EXP_Variable, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_VariableFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_Variable);

    if (children != null) {
      return makeEXP_Variable(
        PICOIDFromTerm((aterm.ATerm) children.get(0))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.Variable arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getVariableName().toTerm());
    return factory.make(pattern_EXP_Variable, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.NumberValue makeEXP_NumberValue(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.NumberValue) factory.build( new nl.uva.science.pico.picolanguage.types.exp.NumberValue(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.NumberValue makeEXP_NumberValue(int _numberValue) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeInt(_numberValue)};
    return makeEXP_NumberValue(fun_EXP_NumberValue, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_NumberValueFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_NumberValue);

    if (children != null) {
      return makeEXP_NumberValue(
        ((Integer) children.get(0)).intValue()
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.NumberValue arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(new Integer(arg.getNumberValue()));
    return factory.make(pattern_EXP_NumberValue, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.StringValue makeEXP_StringValue(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.StringValue) factory.build( new nl.uva.science.pico.picolanguage.types.exp.StringValue(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.StringValue makeEXP_StringValue(String _stringValue) {
    aterm.ATerm[] args = new aterm.ATerm[] {factory.makeAppl(factory.makeAFun(_stringValue, 0, true))};
    return makeEXP_StringValue(fun_EXP_StringValue, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_StringValueFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_StringValue);

    if (children != null) {
      return makeEXP_StringValue(
        (String) children.get(0)
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.StringValue arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getStringValue());
    return factory.make(pattern_EXP_StringValue, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.Add makeEXP_Add(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.Add) factory.build( new nl.uva.science.pico.picolanguage.types.exp.Add(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.Add makeEXP_Add(nl.uva.science.pico.picolanguage.types.EXP _left, nl.uva.science.pico.picolanguage.types.EXP _right) {
    aterm.ATerm[] args = new aterm.ATerm[] {_left, _right};
    return makeEXP_Add(fun_EXP_Add, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_AddFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_Add);

    if (children != null) {
      return makeEXP_Add(
        EXPFromTerm((aterm.ATerm) children.get(0)),
        EXPFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.Add arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getLeft().toTerm());
    args.add(arg.getRight().toTerm());
    return factory.make(pattern_EXP_Add, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.Subtract makeEXP_Subtract(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.Subtract) factory.build( new nl.uva.science.pico.picolanguage.types.exp.Subtract(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.Subtract makeEXP_Subtract(nl.uva.science.pico.picolanguage.types.EXP _left, nl.uva.science.pico.picolanguage.types.EXP _right) {
    aterm.ATerm[] args = new aterm.ATerm[] {_left, _right};
    return makeEXP_Subtract(fun_EXP_Subtract, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_SubtractFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_Subtract);

    if (children != null) {
      return makeEXP_Subtract(
        EXPFromTerm((aterm.ATerm) children.get(0)),
        EXPFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.Subtract arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getLeft().toTerm());
    args.add(arg.getRight().toTerm());
    return factory.make(pattern_EXP_Subtract, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.Concatenate makeEXP_Concatenate(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.Concatenate) factory.build( new nl.uva.science.pico.picolanguage.types.exp.Concatenate(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.Concatenate makeEXP_Concatenate(nl.uva.science.pico.picolanguage.types.EXP _left, nl.uva.science.pico.picolanguage.types.EXP _right) {
    aterm.ATerm[] args = new aterm.ATerm[] {_left, _right};
    return makeEXP_Concatenate(fun_EXP_Concatenate, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_ConcatenateFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_Concatenate);

    if (children != null) {
      return makeEXP_Concatenate(
        EXPFromTerm((aterm.ATerm) children.get(0)),
        EXPFromTerm((aterm.ATerm) children.get(1))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.Concatenate arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getLeft().toTerm());
    args.add(arg.getRight().toTerm());
    return factory.make(pattern_EXP_Concatenate, args);
  }

  public nl.uva.science.pico.picolanguage.types.exp.Bracket makeEXP_Bracket(aterm.AFun fun, aterm.ATerm[] args, aterm.ATermList annos) {
    return (nl.uva.science.pico.picolanguage.types.exp.Bracket) factory.build( new nl.uva.science.pico.picolanguage.types.exp.Bracket(this, annos, fun, args));
  }

  public nl.uva.science.pico.picolanguage.types.exp.Bracket makeEXP_Bracket(nl.uva.science.pico.picolanguage.types.EXP _expression) {
    aterm.ATerm[] args = new aterm.ATerm[] {_expression};
    return makeEXP_Bracket(fun_EXP_Bracket, args, factory.getEmpty());
  }

  protected nl.uva.science.pico.picolanguage.types.EXP EXP_BracketFromTerm(aterm.ATerm trm) {
    java.util.List<Object> children = trm.match(pattern_EXP_Bracket);

    if (children != null) {
      return makeEXP_Bracket(
        EXPFromTerm((aterm.ATerm) children.get(0))
      );
    }
    return null;
  }

  public aterm.ATerm toTerm(nl.uva.science.pico.picolanguage.types.exp.Bracket arg) {
    java.util.List<Object> args = new java.util.LinkedList<Object>();
    args.add(arg.getExpression().toTerm());
    return factory.make(pattern_EXP_Bracket, args);
  }

/*genMakeLists*/
  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList() {
    return empty_STATEMENTList;
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem) {
    return makeSTATEMENTList(elem, empty_STATEMENTList);
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT head, nl.uva.science.pico.picolanguage.types.STATEMENTList tail) {
    return makeSTATEMENTList(head, tail, factory.getEmpty());
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(aterm.ATerm head, aterm.ATermList tail, aterm.ATermList annos) {
      return (nl.uva.science.pico.picolanguage.types.STATEMENTList) factory.build(new nl.uva.science.pico.picolanguage.types.STATEMENTList(this, annos, head, tail));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem0, nl.uva.science.pico.picolanguage.types.STATEMENT elem1) {
    return makeSTATEMENTList(elem0, makeSTATEMENTList(elem1));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem0, nl.uva.science.pico.picolanguage.types.STATEMENT elem1, nl.uva.science.pico.picolanguage.types.STATEMENT elem2) {
    return makeSTATEMENTList(elem0, makeSTATEMENTList(elem1, elem2));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem0, nl.uva.science.pico.picolanguage.types.STATEMENT elem1, nl.uva.science.pico.picolanguage.types.STATEMENT elem2, nl.uva.science.pico.picolanguage.types.STATEMENT elem3) {
    return makeSTATEMENTList(elem0, makeSTATEMENTList(elem1, elem2, elem3));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem0, nl.uva.science.pico.picolanguage.types.STATEMENT elem1, nl.uva.science.pico.picolanguage.types.STATEMENT elem2, nl.uva.science.pico.picolanguage.types.STATEMENT elem3, nl.uva.science.pico.picolanguage.types.STATEMENT elem4) {
    return makeSTATEMENTList(elem0, makeSTATEMENTList(elem1, elem2, elem3, elem4));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList makeSTATEMENTList(nl.uva.science.pico.picolanguage.types.STATEMENT elem0, nl.uva.science.pico.picolanguage.types.STATEMENT elem1, nl.uva.science.pico.picolanguage.types.STATEMENT elem2, nl.uva.science.pico.picolanguage.types.STATEMENT elem3, nl.uva.science.pico.picolanguage.types.STATEMENT elem4, nl.uva.science.pico.picolanguage.types.STATEMENT elem5) {
    return makeSTATEMENTList(elem0, makeSTATEMENTList(elem1, elem2, elem3, elem4, elem5));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList reverse(nl.uva.science.pico.picolanguage.types.STATEMENTList arg) {
    nl.uva.science.pico.picolanguage.types.STATEMENTList reversed = makeSTATEMENTList();
    while (!arg.isEmpty()) {
      reversed = makeSTATEMENTList(arg.getHead(), reversed);
      arg = arg.getTail();
    }
    return reversed;
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList concat(nl.uva.science.pico.picolanguage.types.STATEMENTList arg0, nl.uva.science.pico.picolanguage.types.STATEMENTList arg1) {
    nl.uva.science.pico.picolanguage.types.STATEMENTList result = arg1;

    for (nl.uva.science.pico.picolanguage.types.STATEMENTList list = reverse(arg0); !list.isEmpty(); list = list.getTail()) {
      result = makeSTATEMENTList(list.getHead(), result);
    }

    return result;
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList append(nl.uva.science.pico.picolanguage.types.STATEMENTList list, nl.uva.science.pico.picolanguage.types.STATEMENT elem) {
    return concat(list, makeSTATEMENTList(elem));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList() {
    return empty_IDTYPEList;
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem) {
    return makeIDTYPEList(elem, empty_IDTYPEList);
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE head, nl.uva.science.pico.picolanguage.types.IDTYPEList tail) {
    return makeIDTYPEList(head, tail, factory.getEmpty());
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(aterm.ATerm head, aterm.ATermList tail, aterm.ATermList annos) {
      return (nl.uva.science.pico.picolanguage.types.IDTYPEList) factory.build(new nl.uva.science.pico.picolanguage.types.IDTYPEList(this, annos, head, tail));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem0, nl.uva.science.pico.picolanguage.types.IDTYPE elem1) {
    return makeIDTYPEList(elem0, makeIDTYPEList(elem1));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem0, nl.uva.science.pico.picolanguage.types.IDTYPE elem1, nl.uva.science.pico.picolanguage.types.IDTYPE elem2) {
    return makeIDTYPEList(elem0, makeIDTYPEList(elem1, elem2));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem0, nl.uva.science.pico.picolanguage.types.IDTYPE elem1, nl.uva.science.pico.picolanguage.types.IDTYPE elem2, nl.uva.science.pico.picolanguage.types.IDTYPE elem3) {
    return makeIDTYPEList(elem0, makeIDTYPEList(elem1, elem2, elem3));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem0, nl.uva.science.pico.picolanguage.types.IDTYPE elem1, nl.uva.science.pico.picolanguage.types.IDTYPE elem2, nl.uva.science.pico.picolanguage.types.IDTYPE elem3, nl.uva.science.pico.picolanguage.types.IDTYPE elem4) {
    return makeIDTYPEList(elem0, makeIDTYPEList(elem1, elem2, elem3, elem4));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList makeIDTYPEList(nl.uva.science.pico.picolanguage.types.IDTYPE elem0, nl.uva.science.pico.picolanguage.types.IDTYPE elem1, nl.uva.science.pico.picolanguage.types.IDTYPE elem2, nl.uva.science.pico.picolanguage.types.IDTYPE elem3, nl.uva.science.pico.picolanguage.types.IDTYPE elem4, nl.uva.science.pico.picolanguage.types.IDTYPE elem5) {
    return makeIDTYPEList(elem0, makeIDTYPEList(elem1, elem2, elem3, elem4, elem5));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList reverse(nl.uva.science.pico.picolanguage.types.IDTYPEList arg) {
    nl.uva.science.pico.picolanguage.types.IDTYPEList reversed = makeIDTYPEList();
    while (!arg.isEmpty()) {
      reversed = makeIDTYPEList(arg.getHead(), reversed);
      arg = arg.getTail();
    }
    return reversed;
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList concat(nl.uva.science.pico.picolanguage.types.IDTYPEList arg0, nl.uva.science.pico.picolanguage.types.IDTYPEList arg1) {
    nl.uva.science.pico.picolanguage.types.IDTYPEList result = arg1;

    for (nl.uva.science.pico.picolanguage.types.IDTYPEList list = reverse(arg0); !list.isEmpty(); list = list.getTail()) {
      result = makeIDTYPEList(list.getHead(), result);
    }

    return result;
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList append(nl.uva.science.pico.picolanguage.types.IDTYPEList list, nl.uva.science.pico.picolanguage.types.IDTYPE elem) {
    return concat(list, makeIDTYPEList(elem));
  }

/*genTypeFromTermMethods*/
  public nl.uva.science.pico.picolanguage.types.Normal NormalFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.Normal tmp;
    tmp = Normal_NormalFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a Normal: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.Escaped EscapedFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.Escaped tmp;
    tmp = Escaped_EscapedFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a Escaped: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.StrCon StrConFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.StrCon tmp;
    tmp = StrCon_StrConFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a StrCon: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.BoolCon BoolConFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.BoolCon tmp;
    tmp = BoolCon_TrueFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = BoolCon_FalseFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a BoolCon: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.NatCon NatConFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.NatCon tmp;
    tmp = NatCon_NatConFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a NatCon: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.TYPE TYPEFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.TYPE tmp;
    tmp = TYPE_NaturalFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = TYPE_StringFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = TYPE_NilTypeFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a TYPE: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.PICOID PICOIDFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.PICOID tmp;
    tmp = PICOID_PICOIDFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a PICOID: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTS STATEMENTSFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.STATEMENTS tmp;
    tmp = STATEMENTS_StatementsFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a STATEMENTS: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.DECLARATIONS DECLARATIONSFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.DECLARATIONS tmp;
    tmp = DECLARATIONS_DeclarationsFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a DECLARATIONS: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.PROGRAM PROGRAMFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.PROGRAM tmp;
    tmp = PROGRAM_MainFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a PROGRAM: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.DECLS DECLSFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.DECLS tmp;
    tmp = DECLS_VariablesFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a DECLS: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPE IDTYPEFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.IDTYPE tmp;
    tmp = IDTYPE_VariableFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a IDTYPE: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENTFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.STATEMENT tmp;
    tmp = STATEMENT_AssignmentFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = STATEMENT_ConditionalFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = STATEMENT_LoopFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a STATEMENT: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.EXP EXPFromTerm(aterm.ATerm trm) {
    nl.uva.science.pico.picolanguage.types.EXP tmp;
    tmp = EXP_VariableFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_NumberValueFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_StringValueFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_AddFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_SubtractFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_ConcatenateFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    tmp = EXP_BracketFromTerm(trm);
    if (tmp != null) {
      return tmp;
    }

    throw new IllegalArgumentException("This is not a EXP: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList STATEMENTListFromTerm(aterm.ATerm trm) {
     if (trm instanceof aterm.ATermList) {
        aterm.ATermList list = ((aterm.ATermList) trm).reverse();
        nl.uva.science.pico.picolanguage.types.STATEMENTList result = makeSTATEMENTList();
        for (; !list.isEmpty(); list = list.getNext()) {
           nl.uva.science.pico.picolanguage.types.STATEMENT elem = STATEMENTFromTerm(list.getFirst());
            result = makeSTATEMENTList(elem, result);
        }
        return result;
     }
     throw new RuntimeException("This is not a STATEMENTList: " + trm);
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList IDTYPEListFromTerm(aterm.ATerm trm) {
     if (trm instanceof aterm.ATermList) {
        aterm.ATermList list = ((aterm.ATermList) trm).reverse();
        nl.uva.science.pico.picolanguage.types.IDTYPEList result = makeIDTYPEList();
        for (; !list.isEmpty(); list = list.getNext()) {
           nl.uva.science.pico.picolanguage.types.IDTYPE elem = IDTYPEFromTerm(list.getFirst());
            result = makeIDTYPEList(elem, result);
        }
        return result;
     }
     throw new RuntimeException("This is not a IDTYPEList: " + trm);
  }

/*genTypeFromMethods*/
  public nl.uva.science.pico.picolanguage.types.Normal NormalFromString(String str) {
    return NormalFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.Normal NormalFromFile(java.io.InputStream stream) throws java.io.IOException {
    return NormalFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.Escaped EscapedFromString(String str) {
    return EscapedFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.Escaped EscapedFromFile(java.io.InputStream stream) throws java.io.IOException {
    return EscapedFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.StrCon StrConFromString(String str) {
    return StrConFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.StrCon StrConFromFile(java.io.InputStream stream) throws java.io.IOException {
    return StrConFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.BoolCon BoolConFromString(String str) {
    return BoolConFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.BoolCon BoolConFromFile(java.io.InputStream stream) throws java.io.IOException {
    return BoolConFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.NatCon NatConFromString(String str) {
    return NatConFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.NatCon NatConFromFile(java.io.InputStream stream) throws java.io.IOException {
    return NatConFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.TYPE TYPEFromString(String str) {
    return TYPEFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.TYPE TYPEFromFile(java.io.InputStream stream) throws java.io.IOException {
    return TYPEFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.PICOID PICOIDFromString(String str) {
    return PICOIDFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.PICOID PICOIDFromFile(java.io.InputStream stream) throws java.io.IOException {
    return PICOIDFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTS STATEMENTSFromString(String str) {
    return STATEMENTSFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTS STATEMENTSFromFile(java.io.InputStream stream) throws java.io.IOException {
    return STATEMENTSFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.DECLARATIONS DECLARATIONSFromString(String str) {
    return DECLARATIONSFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.DECLARATIONS DECLARATIONSFromFile(java.io.InputStream stream) throws java.io.IOException {
    return DECLARATIONSFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.PROGRAM PROGRAMFromString(String str) {
    return PROGRAMFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.PROGRAM PROGRAMFromFile(java.io.InputStream stream) throws java.io.IOException {
    return PROGRAMFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.DECLS DECLSFromString(String str) {
    return DECLSFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.DECLS DECLSFromFile(java.io.InputStream stream) throws java.io.IOException {
    return DECLSFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPE IDTYPEFromString(String str) {
    return IDTYPEFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPE IDTYPEFromFile(java.io.InputStream stream) throws java.io.IOException {
    return IDTYPEFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENTFromString(String str) {
    return STATEMENTFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENT STATEMENTFromFile(java.io.InputStream stream) throws java.io.IOException {
    return STATEMENTFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.EXP EXPFromString(String str) {
    return EXPFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.EXP EXPFromFile(java.io.InputStream stream) throws java.io.IOException {
    return EXPFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList STATEMENTListFromString(String str) {
    return STATEMENTListFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.STATEMENTList STATEMENTListFromFile(java.io.InputStream stream) throws java.io.IOException {
    return STATEMENTListFromTerm(factory.readFromFile(stream));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList IDTYPEListFromString(String str) {
    return IDTYPEListFromTerm(factory.parse(str));
  }

  public nl.uva.science.pico.picolanguage.types.IDTYPEList IDTYPEListFromFile(java.io.InputStream stream) throws java.io.IOException {
    return IDTYPEListFromTerm(factory.readFromFile(stream));
  }

/*genForwardingAlternativeMethods*/
/*genForwardingMakeLists*/
/*genForwardingTypeFromTermMethods*/
/*TODOgenForwardingTypeFromMethods*/
  public static String charsToString(aterm.ATerm arg) {
    aterm.ATermList list = (aterm.ATermList) arg;
    StringBuffer str = new StringBuffer();

    for ( ; !list.isEmpty(); list = list.getNext()) {
      str.append((char) ((aterm.ATermInt) list.getFirst()).getInt());
    }

    return str.toString();
  }

  public static char charToByte(aterm.ATerm arg) {

      return((char) ((aterm.ATermInt) arg).getInt());
  }

  public aterm.ATerm stringToChars(String str) {
    int len = str.length();
    byte chars[] = str.getBytes();
    aterm.ATermList result = getPureFactory().makeList();

    for (int i = len - 1; i >= 0; i--) {
      result = result.insert(getPureFactory().makeInt(chars[i]));
    }

    return result;
  }

  public aterm.ATerm byteToChar(char ch) {
      return getPureFactory().makeInt(ch);
  }

}
